/*************************************************************
 * File: UserServiceImpl.java
 * Copyright (c) 2012
 * Author: Huang Shaobin
 * Email: Shaobin.Software@gmail.com Shaobin_Software@163.com 
 * Date: Feb 11, 2013
 * Description: 
 ************************************************************/

package snow.biz.system.service.impl;

import org.apache.commons.lang.StringUtils;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import snow.biz.base.service.impl.HibernateBaseServiceImpl;
import snow.biz.system.model.Group;
import snow.biz.system.model.User;
import snow.biz.system.service.IUserService;
import snow.core.enums.Status;

/**
 * 用户相关操作的服务实现
 * 
 * @author Shaobin.Software@gmail.com Shaobin_Software@163.com
 * @version 1.0
 */
public class UserServiceImpl extends HibernateBaseServiceImpl implements IUserService {

	public User searchUserFrom(Group group, String loginName) {
		final DetachedCriteria criteria = DetachedCriteria.forClass(User.class);
		criteria.add(Restrictions.eq("group", group)); // 集团信息
		criteria.add(Restrictions.eq("loginName", StringUtils.trim(loginName))); // 用户名
		criteria.add(Restrictions.eq("status", Status.SUCCESS)); // 用户状态
		return super.findByCriteriaForUnique(criteria, User.class);
	}

}
